import {defineConfig} from 'vite'

import { fileURLToPath, URL } from 'node:url';
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import {PrimeVueResolver} from '@primevue/auto-import-resolver';

// https://vitejs.dev/config/
export default defineConfig({
    base: '/',
    plugins: [
        vue(),
        Components({
            resolvers: [
                PrimeVueResolver()
            ],
        }),
    ],
    resolve: {
        alias: {
             '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        proxy: {
            '/api': {
                // target: 'http://192.168.32.129:9000',
                target: 'http://touni.top:7006',
                changeOrigin: true, //需要代理跨域
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
            '^/ws': {
                // target: 'http://192.168.30.9:9000',
                target: 'ws://192.168.32.129:9000',
                wss: true,
                rewriteWsOrigin: true,
                rewrite: (path) => path.replace(/^\/ws/, ''),
            },
        },
    },
})
